﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

public partial class logon : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogon_Click(object sender, EventArgs e)
    {
        //if (Session["CHK_CODE"].ToString() != txtChkCode.Text)
        //{
        //    txtChkCode.Text = "";
        //    lblError.Text = "图形检验码错误！";
        //    return;
        //}
        Session["CHK_CODE"]="slkjfleijl39sfdpojs*ikdsijlfe";
        SqlCommand cmd = new SqlCommand();
        DataTable dt = new DataTable();
        cmd.CommandText = "logon";
        SqlParameter para = cmd.Parameters.AddWithValue("@uid", txtUID.Text);
        para = cmd.Parameters.AddWithValue("@pwd", txtPwd.Text);
        int i;
        try
        {
            i = TinyDAL.Exec(ref cmd,ref dt);
            switch (i)
            {
                case 0:
                    Session["UID"] = dt.Rows[0]["uid"].ToString();
                    Session["NAME"] = dt.Rows[0]["name"].ToString();
                    Response.Redirect("default.aspx");
                    break;
                case 1:
                    lblError.Text = "登录失败！";
                    break;
                default:
                    lblError.Text = "未知错误：" + i.ToString();
                    break;
            }

        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
}
